﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
    public abstract class ReadingBase : StreamBase
    {
        public string ReadString(uint length)
        {
            return ReadString((int)length);
        }

        public string ReadString(int length)
        {
            var sb = new StringBuilder();
            for (int i = 0; i < length; i++)
            {
                byte t = Reader.ReadByte();
                if (t != 0)
                {
                    sb.Append(char.ConvertFromUtf32((int)t));
                }
            }
            return sb.ToString();
        }

        public string ReadString()
        {
            var sb = new StringBuilder();
            try
            {
                char tbBlock;
                while ((tbBlock = Reader.ReadChar()) != 0)
                    sb.Append(tbBlock);
            }
            catch //(Exception ex)
            {
                // Reader.BaseStream.Position++;
                //whatever
            }
            return sb.ToString();
        }

        public UInt64 popGuid()
        {
            return Reader.popGuid();
        }

        public Coord3 ReadCoord3()
        {
            return Reader.ReadCoord3();
        }

        public Coord4 ReadCoord4()
        {
            return Reader.ReadCoord4();
        }

        public MovementJump ReadMovementJump()
        {
            return Reader.ReadMovementJump();
        }

        public MovementFall ReadMovementFall()
        {
            return Reader.ReadMovementFall();
        }

        public MovementTransport ReadMovementTransport(int clientbuild, uint opcode)
        {
            return Reader.ReadMovementTransport(clientbuild, opcode);
        }

        public int Read(byte[] buffer, int index, int count)
        {
            return Reader.Read(buffer, index, count);
        }

        public int Read(char[] buffer, int index, int count)
        {
            return Reader.Read(buffer, index, count);
        }

        public bool ReadBoolean()
        {
            return Reader.ReadBoolean();
        }

        public byte ReadByte()
        {
            return Reader.ReadByte();
        }

        public byte[] ReadBytes(int count)
        {
            return Reader.ReadBytes(count);
        }

        public byte[] ReadBytes(long count)
        {
            return ReadBytes((int)count);
        }

        public char ReadChar()
        {
            return Reader.ReadChar();
        }

        public char[] ReadChars(int count)
        {
            return Reader.ReadChars(count);
        }

        public decimal ReadDecimal()
        {
            return Reader.ReadDecimal();
        }

        public double ReadDouble()
        {
            return Reader.ReadDouble();
        }

        public short ReadInt16()
        {
            return Reader.ReadInt16();
        }

        public int ReadInt32()
        {
            return Reader.ReadInt32();
        }

        public uint ReadUInt()
        {
            return Reader.ReadUInt32();
        }

        public int ReadInt()
        {
            return Reader.ReadInt32();
        }

        public float ReadFloat()
        {
            return Reader.ReadSingle();
        }

        public long ReadInt64()
        {
            return Reader.ReadInt64();
        }

        public sbyte ReadSByte()
        {
            return Reader.ReadSByte();
        }

        public float ReadSingle()
        {
            return Reader.ReadSingle();
        }

        public ushort ReadUInt16()
        {
            return Reader.ReadUInt16();
        }

        public uint ReadUInt32()
        {
            return Reader.ReadUInt32();
        }

        public ulong ReadUInt64()
        {
            return Reader.ReadUInt64();
        }

        public string ValuesDump()
        {
            return ValuesDump(AvailableBytes);
        }

        public string FloatDump()
        {
            return FloatDump(AvailableBytes);
        }

        public string ValuesDump(int count)
        {
            return Reader.ValuesDump(count);
        }

        public string FloatDump(int count)
        {
            return Reader.FloatDump(count);
        }
    }
}
